#include "stdafx.h"
#include "CStatic.h"

NAMESPACE_UI_BEGIN
const UINT_32 STATIC_AUTOREPAINT = AutoRepaintTextChanged | AutoRepaintTextFormatChanged | AutoRepaintBackImageChanged;

CStatic::CStatic()
	: CControl(0, 0, 0, 0, nullptr, nullptr, STATIC_AUTOREPAINT, 0)
{
}

CStatic::CStatic(int_32 iX, int_32 iY, int_32 iWidth, int_32 iHeight)
	: CControl(iX, iY, iWidth, iHeight, nullptr, nullptr, STATIC_AUTOREPAINT, 0)
{
}

CStatic::~CStatic()
{

}

const COID & CStatic::GetOID() const
{
	return OID_STATIC;
}

void CStatic::OnPaint(IPaint * pPaint, const CRectInt32 & rectClip) const
{
	CRectFloat32 rect = GetClient();
	if(m_pImage)
		pPaint->DrawImageWithMode(m_pImage, 
		rect, 
		CRectFloat32(0, 0, (float_32)m_pImage->GetWidth(), (float_32)m_pImage->GetHeight()), m_eImageMode);

	if(!m_text.IsEmpty())
		pPaint->DrawString(m_text, m_text.GetLength(), 0.0f, 0.0f, rect.Width, rect.Height, &CSolidBrush(m_uiForeColor));
}

NAMESPACE_UI_END
